<#assign baseURL = springMacroRequestContext.getContextPath() />
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>拓深科技</title>
<#include "./css.ftl">
    <link href="assets/jQuery-File-Upload-9.12.3/css/jquery.fileupload.css" rel="stylesheet"/>
    <link href="assets/jQuery-File-Upload-9.12.3/css/jquery.fileupload-ui.css" rel="stylesheet"/>
</head>
<body>
<div id="wrapper">

<#include "./left_nav.ftl">

    <div id="page-wrapper" class="gray-bg dashbard-1 animated fadeInRight">
    <#include "./top_nav.ftl">
        <div class="wrapper wrapper-content ">
          <div class="row">

          <#if (role_type_id > 2)>

                  <div class="widget red-bg p-lg text-center">
                      <div class="m-b-lg">
                          <i class="fa fa-bell fa-4x" style="margin-bottom: 20px"></i>
                          <h1 class="font-bold no-margins">
                              权限不足
                          </h1>
                      </div>
                  </div>

          <#else >
              <div class="col-md-3">
                  <div class="panel panel-default">
                      <div class="panel-heading">
                          <h4 class="panel-title"><b>当前区域数据</b></h4>
                      </div>
                      <div class="panel-body">
                            <pre class="prettyprint" style="border: none;height: 650px;">
                                <div id="loction_tree"></div>
                            </pre>
                      </div>
                  </div>
              </div>

              <div class="col-md-9">
                  <div id="loction_setting" class="panel panel-default">
                      <div class="panel-header">
                          <h4 class="panel-title" style="margin-top: 5px;margin-left: 5px;"><b>地理信息设置</b></h4>
                      </div>
                      <div class="panel-body">
                          <div class="row">
                              <div class="col-sm-12">
                                  <div class="nav-tabs-custom">
                                      <ul class="nav nav-tabs">
                                          <li class="active"><a href="#map_tab_floor" data-toggle="tab">楼层信息</a> </li>
                                          <li><a href="#map_tab_build" data-toggle="tab">建筑物信息</a> </li>
                                          <li><a href="#map_tab_area" data-toggle="tab">区域信息</a> </li>
                                      </ul>
                                      <div class="tab-content">
                                          <div class="tab-pane active" id="map_tab_floor">
                                              <div class="row">
                                                  <div class="col-sm-12">
                                                      <div class="panel panel-default">
                                                          <div class="panel-header">
                                                              <h4 class="panel-title"style="margin-top: 5px;margin-left: 5px;">录入数据</h4>
                                                          </div>
                                                          <div class="panel-body">
                                                              <div class="col-sm-12" id="floor_input_div">
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>区域</label>
                                                                          <select id="floor_input_div_area_select" class="form-control select2 floor_input_div_area_select_class" style="width: 100%;"></select>
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>建筑物</label>
                                                                          <select id="floor_input_div_build_select" class="form-control select2 floor_input_div_build_select_class" style="width: 100%;"></select>
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>楼层</label>
                                                                          <input id="mapFloorInput" type="text" class="form-control" placeholder="请输入楼层信息">
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-2 col-sm-offset-1">
                                                                      <button id="mapFloorSaveBtn" type="button" class="btn btn-success fa fa-save btn-block" style="margin-top: 28px">保存</button>
                                                                  </div>
                                                              </div>
                                                          </div>
                                                      </div>
                                                  </div>
                                                  <div class="col-sm-12">
                                                      <div class="panel panel-default">
                                                          <div class="panel-header">
                                                              <h4 class="panel-title" style="margin-top: 5px;margin-left: 5px;">删除数据</h4>
                                                          </div>
                                                          <div class="panel-body">
                                                              <div class="col-sm-12" id="floor_del_div">
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>区域</label>
                                                                          <select id="floor_del_div_area_select" class="form-control select2 floor_del_div_area_select_class" style="width: 100%;"></select>
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>建筑物</label>
                                                                          <select id="floor_del_div_build_select" class="form-control select2 floor_del_div_build_select_class" style="width: 100%;"></select>
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>楼层</label>
                                                                          <select id="floor_del_div_floor_select" class="form-control select2 floor_del_div_floor_select_class" style="width: 100%;"></select>
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-2 col-sm-offset-1">
                                                                      <button id="mapFloorDelBtn" type="button" class="btn btn-danger fa fa-close btn-block " style="margin-top: 28px">删除</button>
                                                                  </div>
                                                              </div>
                                                          </div>
                                                      </div>
                                                  </div>
                                                  <div class="col-sm-12">
                                                      <div class="panel panel-default">
                                                          <div class="panel-header">
                                                              <h4 class="panel-title" style="margin-top: 5px;margin-left: 5px;">修改数据</h4>
                                                          </div>
                                                          <div class="panel-body">
                                                              <div class="col-sm-12" id="floor_change_div">
                                                                  <div class="col-sm-2">
                                                                      <div class="form-group">
                                                                          <label>区域</label>
                                                                          <select id="floor_change_div_area_select" class="form-control select2 floor_change_div_area_select_class" style="width: 100%;"></select>
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-2">
                                                                      <div class="form-group">
                                                                          <label>建筑物</label>
                                                                          <select id="floor_change_div_build_select" class="form-control select2 floor_change_div_build_select_class" style="width: 100%;"></select>
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-2">
                                                                      <div class="form-group">
                                                                          <label>原始楼层</label>
                                                                          <select id="floor_change_div_floor_select" class="form-control select2 floor_change_div_floor_select_class" style="width: 100%;"></select>
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-2">
                                                                      <div class="form-group">
                                                                          <label>修改楼层</label>
                                                                          <input id="mapFloorChangeInput" type="text" class="form-control" placeholder="请输入楼层信息">
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-2 col-sm-offset-2">
                                                                      <button id="mapFloorChangeBtn" type="button" class="btn btn-warning fa  fa-file-text btn-block " style="margin-top: 28px">修改</button>
                                                                  </div>
                                                              </div>
                                                          </div>
                                                      </div>
                                                  </div>

                                              </div>

                                          </div>
                                          <div class="tab-pane" id="map_tab_build">
                                              <div class="row">
                                                  <div class="col-sm-12">
                                                      <div class="panel panel-default">
                                                          <div class="panel-header">
                                                              <h4 class="panel-title"style="margin-top: 5px;margin-left: 5px;">录入数据</h4>
                                                          </div>
                                                          <div class="panel-body">
                                                              <div class="col-sm-12" id="build_input_div">
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>区域</label>
                                                                          <select id="build_input_div_area_select" class="form-control select2 build_input_div_area_select_class" style="width: 100%;"></select>
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>建筑物</label>
                                                                          <input id="mapBuildInput" type="text" class="form-control" placeholder="请输入建筑物名称">
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-2 col-sm-offset-1">
                                                                      <button id="mapBuildSaveBtn" type="button" class="btn btn-success fa fa-save btn-block " style="margin-top: 28px">保存</button>
                                                                  </div>
                                                              </div>
                                                          </div>
                                                      </div>
                                                  </div>
                                                  <div class="col-sm-12">
                                                      <div class="panel panel-default">
                                                          <div class="panel-header">
                                                              <h4 class="panel-title"style="margin-top: 5px;margin-left: 5px;">删除数据</h4>
                                                          </div>
                                                          <div class="panel-body">
                                                              <div class="col-sm-12" id="build_del_div">
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>区域</label>
                                                                          <select id="build_del_div_area_select" class="form-control select2 build_del_div_area_select_class" style="width: 100%;"></select>
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>建筑物</label>
                                                                          <select id="build_del_div_build_select" class="form-control select2 build_del_div_build_select_class" style="width: 100%;"></select>
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-2 col-sm-offset-1">
                                                                      <button id="mapBuildDelBtn" type="button" class="btn btn-danger fa fa-close btn-block " style="margin-top: 28px">删除</button>
                                                                  </div>
                                                              </div>
                                                          </div>
                                                      </div>
                                                  </div>
                                                  <div class="col-sm-12">
                                                      <div class="panel panel-default" >
                                                          <div class="panel-header">
                                                              <h4 class="panel-title"style="margin-top: 5px;margin-left: 5px;">修改数据</h4>
                                                          </div>
                                                          <div class="panel-body">
                                                              <div class="col-sm-12" id="build_change_div">
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>区域</label>
                                                                          <select id="build_change_div_area_select" class="form-control select2 build_change_div_area_select_class" style="width: 100%;"></select>
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>原始建筑物</label>
                                                                          <select id="build_change_div_build_select" class="form-control select2 build_change_div_build_select_class" style="width: 100%;"></select>
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>修改建筑物</label>
                                                                          <input id="mapBuildChangeInput" type="text" class="form-control" placeholder="请输入建筑物名称">
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-2 col-sm-offset-1">
                                                                      <button id="mapBuildChangeBtn" type="button" class="btn btn-warning fa  fa-file-text btn-block " style="margin-top: 28px">修改</button>
                                                                  </div>
                                                              </div>
                                                          </div>
                                                      </div>
                                                  </div>
                                              </div>
                                          </div>
                                          <div class="tab-pane" id="map_tab_area">
                                              <div class="row">
                                                  <div class="col-sm-12">
                                                      <div class="panel panel-default">
                                                          <div class="panel-header">
                                                              <h4 class="panel-title"style="margin-top: 5px;margin-left: 5px;">录入数据</h4>
                                                          </div>
                                                          <div class="panel-body">
                                                              <div class="col-sm-12">
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>区域数据</label>
                                                                          <input id="mapAreaInput" type="text" class="form-control" placeholder="请输入区域名称">
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-2 col-sm-offset-1">
                                                                      <button id="mapAreaSaveBtn" type="button" class="btn btn-success btn-block fa fa-save" style="margin-top: 28px">保存</button>
                                                                  </div>
                                                              </div>
                                                          </div>
                                                      </div>
                                                  </div>
                                                  <div class="col-sm-12">
                                                      <div class="panel panel-default">
                                                          <div class="panel-header">
                                                              <h4 class="panel-title"style="margin-top: 5px;margin-left: 5px;">删除数据</h4>
                                                          </div>
                                                          <div class="panel-body">
                                                              <div class="col-sm-12" id="area_del_div">
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>区域数据</label>
                                                                          <select id="area_del_div_area_select" class="form-control select2 area_del_div_area_select_class" style="width: 100%;"></select>
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-2 col-sm-offset-1">
                                                                      <div class="form-group">
                                                                          <button id="mapAreaDelBtn" type="button" class="btn btn-danger btn-block fa fa-close" style="margin-top: 28px">删除</button>
                                                                      </div>
                                                                  </div>
                                                              </div>
                                                          </div>
                                                      </div>
                                                  </div>
                                                  <div class="col-sm-12">
                                                      <div class="panel panel-default">
                                                          <div class="panel-header">
                                                              <h4 class="panel-title"style="margin-top: 5px;margin-left: 5px;">修改数据</h4>
                                                          </div>
                                                          <div class="panel-body">
                                                              <div class="col-sm-12" id="area_change_div">
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>原始区域数据</label>
                                                                          <select id="area_change_div_area_select" class="form-control select2 area_change_div_area_select_class" style="width: 100%;"></select>
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-3">
                                                                      <div class="form-group">
                                                                          <label>修改数据</label>
                                                                          <input id="mapAreaChangeInput" type="text" class="form-control" placeholder="请输入区域信息">
                                                                      </div>
                                                                  </div>
                                                                  <div class="col-sm-2 col-sm-offset-1">
                                                                      <button id="mapAreaChangeBtn" type="button" class="btn btn-warning fa  fa-file-text btn-block " style="margin-top: 28px">修改</button>
                                                                  </div>
                                                              </div>
                                                          </div>
                                                      </div>
                                                  </div>
                                              </div>
                                          </div>
                                      </div>
                                  </div>
                              </div>
                          </div>
                          <div class="row">
                              <div class="panel panel-default" style="margin-bottom: 0px; margin-left: 15px;">
                                  <div class="panel-header">
                                      <h4 class="panel-title"style="margin-top: 5px;margin-left: 5px;">修改地图数据(<b style="color: red">!点击左侧区域再进行图片上传</b>)</h4>
                                  </div>
                                  <div class="panel-body">
                                      <div class="row">
                                          <div class="col-sm-2" style="display: none;"><input id="photoCover" class="input-large" type="text" style="height:33px;"></div>
                                          <div class="col-sm-2">
                                              <form id="fileForm" action="" method="post" enctype="multipart/form-data"   target="frameFile" >
                                                    <span class="btn btn-info fa fa-folder-open   fileinput-button">
                                                    <span>打开地图</span>
                                                    <input   id="map_file" type="file" multiple  name="file" accept="image/jpeg,image/png">
                                                </span>
                                                  <input id="submit" name="submit" type="submit" style="display: none">
                                              </form>
                                              <iframe id="frameFile" name="frameFile" style="display: none;"></iframe>
                                          </div>
                                      </div>
                                  </div>
                              </div>
                          </div>
                      </div>
                  </div>
              </div>
          </#if>




          </div>
        </div>
    <#include "./bottom_nav.ftl">
    </div>

</div>


<#include "./js.ftl">


<#if (role_type_id > 2)>
<#else >
<script>

    var server = "http://"+getURL()+"${baseURL}";
    var mapId;
    var locationObjArr;
    $(function () {
        socketInit(server.substring(5));
        init();
        treeinit();
    });
    function init() {
        $.ajax({
            url: "${baseURL}/xkGeoLocation/getTree",
            async:false,
            success:function (data_in) {
                var jsonObj = data_in;
                var data = [];
                for(var i  in jsonObj.data){
                    var level1 = jsonObj.data;
                    if(i==0){
                        var level1Obj = {
                            text:level1[i].name,
                            id:level1[i].id,
                            icon:"glyphicon glyphicon-globe text-yellow",
                            state: {"opened" : true }
                        };
                    }else {
                        var level1Obj = {
                            text:level1[i].name,
                            id:level1[i].id,
                            icon:"glyphicon glyphicon-globe text-yellow",
                            state: {"opened" : false }
                        };
                    }
                    if(level1[i].picture ==""){
                        level1Obj.text = level1[i].name + "(无地图)";
                    }
                    if(level1[i].children != null)
                    {
                        var level2 = level1[i].children;
                        var level2Arr = [];
                        for(var j in level2){
                            if(i==0 && j==0){
                                var level2Obj = {
                                    text: level2[j].name,
                                    id: level2[j].id,
                                    icon: "glyphicon glyphicon-home text-yellow",
                                    state: {"opened" : true }
                                };
                            }else {
                                var level2Obj = {
                                    text: level2[j].name,
                                    id: level2[j].id,
                                    icon: "glyphicon glyphicon-home text-yellow",
                                    state: {"opened" : false }
                                };
                            }
                            if(level2[j].picture ==""){
                                level2Obj.text = level2[j].name + "(无地图)";
                            }
                            if(level2[j].children != null)
                            {
                                var level3 = level2[j].children;
                                var level3Arr = [];
                                for(var k in level3){
                                    var level3Obj = {
                                        text: level3[k].name,
                                        id: level3[k].id,
                                        icon: "glyphicon glyphicon-flag text-yellow"
                                    };
                                    if(level3[k].picture ==""){
                                        level3Obj.text = level3[k].name + "(无地图)";
                                    }
                                    level3Arr.push(level3Obj);
                                }
                                level2Obj .children = level3Arr;
                            }
                            level2Arr.push(level2Obj);
                        }
                        level1Obj.children = level2Arr;
                    }
                    data.push(level1Obj);
                }
                locationObjArr = data;
            }
        });

        $('#floor_input_div').cxSelect({
            selects:['floor_input_div_area_select_class','floor_input_div_build_select_class',],
            jsonName:'text',
            jsonValue:'id',
            jsonSub:'children',
            data:locationObjArr
        });
        $('#floor_del_div').cxSelect({
            selects:['floor_del_div_area_select_class','floor_del_div_build_select_class','floor_del_div_floor_select_class'],
            jsonName:'text',
            jsonValue:'id',
            jsonSub:'children',
            data:locationObjArr
        });
        $('#floor_change_div').cxSelect({
            selects:['floor_change_div_area_select_class','floor_change_div_build_select_class','floor_change_div_floor_select_class'],
            jsonName:'text',
            jsonValue:'id',
            jsonSub:'children',
            data:locationObjArr
        });

        $('#build_input_div').cxSelect({
            selects:['build_input_div_area_select_class',],
            jsonName:'text',
            jsonValue:'id',
            data:locationObjArr
        });
        $('#build_del_div').cxSelect({
            selects:['build_del_div_area_select_class','build_del_div_build_select_class'],
            jsonName:'text',
            jsonValue:'id',
            jsonSub:'children',
            data:locationObjArr
        });
        $('#build_change_div').cxSelect({
            selects:['build_change_div_area_select_class','build_change_div_build_select_class'],
            jsonName:'text',
            jsonValue:'id',
            jsonSub:'children',
            data:locationObjArr
        });

        $('#area_del_div').cxSelect({
            selects:['area_del_div_area_select_class'],
            jsonName:'text',
            jsonValue:'id',
            data:locationObjArr
        });
        $('#area_change_div').cxSelect({
            selects:['area_change_div_area_select_class'],
            jsonName:'text',
            jsonValue:'id',
            data:locationObjArr
        });
    };
    function treeinit(){
        $('#loction_tree').data('jstree',false).empty();
        $('#loction_tree').jstree({
            'core' : {
                'data' : locationObjArr,
                'async' : true,
            }
        });
    }
    $('#loction_tree').on('select_node.jstree', function (e, data) {
        $('#loction_tree').jstree("uncheck_all");
        mapId = data.node.id;
        loadServerMap(mapId);
    });
    $('#upload').click(function(){
        $('#fileForm').attr("action","${baseURL}/xkGeoLocationMap/mapUpload?id="+mapId);
        $('#submit').click();
        $('#fileName').empty();
        $('#fileName').html("附件体积请勿超过20MB.")

    })
    function getObjectURL(file) {
        var url = null;
        if (window.createObjectURL != undefined) {
            url = window.createObjectURL(file);
        } else if (window.URL != undefined) {
            url = window.URL.createObjectURL(file);
        } else if (window.webkitURL != undefined) {
            url = window.webkitURL.createObjectURL(file);
        }
        return url;
    }
    $('input[id=map_file]').change(function() {
        var mp = $('#photoCover');
        mp.val($(this).val());
        if(mp.val() != null){
            var objUrl = getObjectURL(this.files[0]) ;
            if (objUrl) {
                layer.open({
                    type:1,
                    area: ['800px', '600px'],
                    title: '地图上传',
                    skin:'layui-layer-lan',
                    content:'<div class="row"><div id="map_div_layer" ></div></div>',
                    btn:['确认上传','取消'],
                    btn1:function (index, layero) {
                        if(mapId === undefined){
                            swal({
                                title: "请先在左侧点选目标建筑物",
                                type: "warning"
                            });
                            return;
                        }
                        var formData = new FormData($("#fileForm")[0]);
                        $.ajax({
                            async: false,
                            cache: false,
                            contentType: false,
                            processData: false,
                            url:"${baseURL}/xkGeoLocationMap/mapUpload?id="+mapId,
                            type:"post",
                            data:formData,
                            success:function(data){
                                layer.alert('图片上传成功！',{
                                    closeBtn: 0
                                });
                                layer.close(index);
                                $('#map_file').val(null);
                                $('#photoCover').val(null);
                                location.reload();
                            },
                            error:function(data){
                                layer.close(index);
                            }
                        })
                    },
                    btn2:function (index, layero) {
                        $('#map_div').empty();
                        $('#map_file').val(null);
                        $('#photoCover').val(null);
                        layer.close(index);
                    },
                    success:function(){
                        $('#map_div_layer').empty();
                        var img = '<img id="show_map" class="col-sm-12" src="'+objUrl+'" />';
                        $('#map_div_layer').append(img);
                        mp.val(objUrl);
                    }
                })

            }
        }
    });
    function loadServerMap(id) {
        layer.open({
            type: 1,
            title: false,
            closeBtn: 0,
            area: '516px',
            offset:['30%','40%'],
            border:false,
            skin: 'layui-layer-nobg',
            shadeClose: true,
            content: '<img id="show_map"style="width: 100%;height: 100%" src="${baseURL}/xkGeoLocationMap/mapDownload?id='+id+'" />'
        });
    }
    function clear() {
        $('#loction_tree').empty();
    }
    $('#mapFloorSaveBtn').click(function () {
        if($('#floor_input_div_build_select').val() == null || $('#mapFloorInput').val()[0] == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var name = $('#mapFloorInput').val();
            if(isSpecial(name)){
                layer.alert('名称不能含有特殊字符',{
                    closeBtn: 0
                });
            }else{
                var parentID = $('#floor_input_div_build_select').val();
                var formDatas = new FormData();
                formDatas.append("name",name);
                formDatas.append("parent_id",parentID);
                formDatas.append("level",3);
                $.ajax({
                    type:"post",
                    contentType : false,
                    processData:false,
                    url: "${baseURL}/xkGeoLocation/add",
                    data:formDatas,
                    success:function (data) {
                        if(data.code == 0){
                            location.reload();
                        }
                        else{
                            layer.alert('操作失败：' + data,{
                                closeBtn: 0
                            });
                        }
                    }
                });
            }

        }
    });
    $('#mapFloorDelBtn').click(function () {
        if($('#floor_del_div_floor_select').val() == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var ID = $('#floor_del_div_floor_select').val();
            $.ajax({
                url: "${baseURL}/xkGeoLocation/delete?id=" + ID,
                success:function (data) {
                    if(data.code == 0){
                        location.reload();
                    }
                    else{
                        layer.alert('操作失败：' + data,{
                            closeBtn: 0
                        });
                    }
                }
            });
        }
    });
    $('#mapFloorChangeBtn').click(function () {
        if($('#floor_change_div_floor_select').val() == null || $('#mapFloorChangeInput').val()[0] == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var name = $('#mapFloorChangeInput').val();
            if(isSpecial(name)){
                layer.alert('名称不能含有特殊字符',{
                    closeBtn: 0
                });
            }else{
                var ID = $('#floor_change_div_floor_select').val();
                var parentID = $('#floor_change_div_build_select').val();
                var formDatas = new FormData();
                formDatas.append("id",ID);
                formDatas.append("name",name);
                formDatas.append("parent_id",parentID);
                formDatas.append("level",3);
                $.ajax({
                    type:"post",
                    contentType : false,
                    processData:false,
                    url: "${baseURL}/xkGeoLocation/update",
                    data:formDatas,
                    success:function (data) {
                        if(data.code == 0){
                            location.reload();
                        }
                        else{
                            layer.alert('操作失败：' + data,{
                                closeBtn: 0
                            });
                        }
                    }
                });
            }

        }
    });
    $('#mapBuildSaveBtn').click(function () {
        if($('#build_input_div_area_select').val() == null || $('#mapBuildInput').val()[0] == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var name = $('#mapBuildInput').val();
            if(isSpecial(name)){
                layer.alert('名称不能含有特殊字符',{
                    closeBtn: 0
                });
            }else{
                var parentID = $('#build_input_div_area_select').val();
                var formDatas = new FormData();
                formDatas.append("name",name);
                formDatas.append("parent_id",parentID);
                formDatas.append("level",2);
                $.ajax({
                    type:"post",
                    contentType : false,
                    processData:false,
                    url: "${baseURL}/xkGeoLocation/add",
                    data:formDatas,
                    success:function (data) {
                        if(data.code == 0){
                            location.reload();
                        }
                        else{
                            layer.alert('操作失败：' + data,{
                                closeBtn: 0
                            });
                        }
                    }
                });
            }

        }
    });
    $('#mapBuildDelBtn').click(function () {
        if($('#build_del_div_build_select').val() == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var ID = $('#build_del_div_build_select').val();
            $.ajax({
                url: "${baseURL}/xkGeoLocation/delete?id="+ID,
                success:function (data) {
                    if(data.code == 0){
                        location.reload();
                    }
                    else{
                        layer.alert('操作失败：' + data,{
                            closeBtn: 0
                        });
                    }
                }
            });
        }
    });
    $('#mapBuildChangeBtn').click(function () {
        if($('#build_change_div_build_select').val() == null || $('#mapBuildChangeInput').val()[0] == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var name = $('#mapBuildChangeInput').val();
            if(isSpecial(name)){
                layer.alert('名称不能含有特殊字符',{
                    closeBtn: 0
                });
            }else {
                var parentID = $('#build_change_div_area_select').val();
                var ID = $('#build_change_div_build_select').val();
                var formDatas = new FormData();
                formDatas.append("id",ID);
                formDatas.append("name",name);
                formDatas.append("parent_id",parentID);
                formDatas.append("level",2);
                $.ajax({
                    type:"post",
                    contentType : false,
                    processData:false,
                    url: "${baseURL}/xkGeoLocation/update" ,
                    data:formDatas,
                    success:function (data) {
                        if(data.code == 0){
                            location.reload();
                        }
                        else{
                            layer.alert('操作失败：' + data,{
                                closeBtn: 0
                            });
                        }
                    }
                });
            }

        }
    });
    $('#mapAreaSaveBtn').click(function () {
        if($('#mapAreaInput').val() == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var name = $('#mapAreaInput').val();
            if(isSpecial(name)){
                layer.alert('名称不能含有特殊字符',{
                    closeBtn: 0
                });
            }else{
                var formDatas = new FormData();
                formDatas.append("name",name);
                formDatas.append("parent_id",0);
                formDatas.append("level",1);
                $.ajax({
                    type:"post",
                    contentType : false,
                    processData:false,
                    url: "${baseURL}/xkGeoLocation/add" ,
                    data:formDatas,
                    success:function (data) {
                        if(data.code == 0){
                            location.reload();
                        }
                        else{
                            layer.alert('操作失败：' + data,{
                                closeBtn: 0
                            });
                        }
                    }
                });
            }

        }
    });
    $('#mapAreaDelBtn').click(function () {
        if($('#area_del_div_area_select').val() == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var ID = $('#area_del_div_area_select').val();
            $.ajax({
                url: "${baseURL}/xkGeoLocation/delete?id=" + ID,
                success:function (data) {
                    if(data.code == 0){
                        location.reload();
                    }
                    else{
                        layer.alert('操作失败：' + data,{
                            closeBtn: 0
                        });
                    }
                }
            });
        }
    });
    $('#mapAreaChangeBtn').click(function () {
        if($('#area_change_div_area_select').val() == null || $('#mapAreaChangeInput').val()[0] == null){
            layer.alert('请输入完整的筛选信息！',{
                closeBtn: 0
            });
        }else{
            var name = $('#mapAreaChangeInput').val();
            if(isSpecial(name)){
                layer.alert('名称不能含有特殊字符',{
                    closeBtn: 0
                });
            }else{
                var ID = parseInt($('#area_change_div_area_select').val());
                var formDatas = new FormData();
                formDatas.append("id",ID);
                formDatas.append("name",name);
                formDatas.append("parent_id",0);
                formDatas.append("level",1);
                $.ajax({
                    type:"post",
                    contentType : false,
                    processData:false,
                    url: "${baseURL}/xkGeoLocation/update",
                    data:formDatas,
                    success:function (data) {
                        if(data.code == 0){
                            location.reload();
                        }
                        else{
                            layer.alert('操作失败：' + data,{
                                closeBtn: 0
                            });
                        }
                    }
                });
            }

        }
    });
    function isSpecial(str){
        var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）&mdash;—|{}【】‘；：”“'。，、？]");
        if(pattern.test(str)){
            return 1;
        }else {
            return 0;
        }
    }


</script>
</#if>
</body>
</html>